package com.wyk.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author WangYuKai
 * @Date 2022/7/21
 * @apiNote
 */
@RestController
public class OrderController {
    //注入模板
    @Autowired
    private RestTemplate restTemplate;

    //要访问的地址
    private static final String ServerURL = "http://nacos-payment-provider";

    @Value("${service-url.nacos-user-service}")
    public String ServerUrl;

    //访问服务端的接口
    @GetMapping("/consumer/payment/get/{id}")
    public String getPayment(@PathVariable("id") Integer id){
       return restTemplate.getForObject(ServerUrl +"/payment/nacos/" + id ,String.class);
    }
}
